how to reverse an array in java without using inbuilt function